package service.impl;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import dao.VideoStateDao;
import entity.VideoState;
import service.VideoStateService;

@Service
public class VideoStateServiceImpl implements VideoStateService {

	//注解的方式注入SqlSessionFactory
	@Autowired
	SqlSessionFactory factory;
	
	@Override
	public VideoState findById(int id) {
		SqlSession sqlSession = null;
		try {
			sqlSession = factory.openSession();
			VideoStateDao dao = sqlSession.getMapper(VideoStateDao.class);
			VideoState videoState = dao.findById(id);
			return videoState;
		} catch (Exception e) {
			System.out.println(e);
		} finally {
			sqlSession.close();
		}
		return null;
	}

}
